home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Languages / Caml Light 0.7 / examples / pascal / envir.ml < prev    next >
Text File  |  1995-06-01  |  564b  |  20 lines

  1. #open "syntaxe";;
  2.  
  3. type 'a env =
  4.   { vars: (string * 'a) list;
  5.     procs: (string * décl_proc) list;
  6.     foncs: (string * décl_fonc) list };;
  7.  
  8. let environnement_initial p f =
  9.   { vars=[]; procs=p; foncs=f };;
  10.  
  11. let ajoute_variable nom info env =
  12.   { vars=(nom,info)::env.vars; procs=env.procs; foncs=env.foncs };;
  13.  
  14. let cherche nom liste =
  15.   try assoc nom liste with Not_found -> raise(Pas_trouvé nom);;
  16.  
  17. let cherche_variable nom env = cherche nom env.vars
  18. and cherche_fonction nom env = cherche nom env.foncs
  19. and cherche_procédure nom env = cherche nom env.procs;;
  20.